package hash.leetcode_1817;

import java.util.HashMap;
import java.util.HashSet;

public class MapAndSet {
    public int[] findingUsersActiveMinutes(int[][] logs, int k) {
        int[] res = new int[k];
        HashMap<Integer, HashSet<Integer>> map = new HashMap<>();
        for (int[] log : logs) {
            if (!map.containsKey(log[0])) {
                HashSet<Integer> set = new HashSet<>();
                set.add(log[1]);
                map.put(log[0], set);
            } else {
                HashSet<Integer> set = map.get(log[0]);
                set.add(log[1]);
            }
        }
        for (Integer key : map.keySet()) {
            int size = map.get(key).size();
            res[size - 1]++;
        }
        return res;
    }
}
